﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using System.Drawing.Design;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace HuanGis
{
    public class ContourEditor
          : UITypeEditor
    {
        private List<ContourLine> _LineList;
        private FDContourLayer _ContourLayer;

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService DialogProvider;
            DialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            ContourLineEditForm MyDialog = new ContourLineEditForm(DialogProvider, _ContourLayer);

            if (DialogProvider.ShowDialog(MyDialog) == DialogResult.OK)
                return MyDialog.resultList;
            else
                return this._LineList;

            //return base.EditValue(context, provider, value);
        }


        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            if (context.Instance is FDContourLayer)
            {
                this._ContourLayer = context.Instance as FDContourLayer;
                this._LineList = (context.Instance as FDContourLayer).ContourLineList;
            }
            else
            {
                return UITypeEditorEditStyle.None;
            }

            return UITypeEditorEditStyle.Modal;


        }

    }

}
